<?php

namespace app\supplier\controller\product;

use app\supplier\controller\Controller;
use app\supplier\model\product\Category as CategoryModel;
use app\common\model\supplier\CategoryStatus as CategoryStatusModel;

/**
 * 商品分类
 */
class Category extends Controller
{
    /**
     * 商品分类列表
     */
    public function index()
    {
        $model = new CategoryModel;
        $list = $model->getCacheTree();
        return $this->renderSuccess('', compact('list'));
    }

    /**
     * 商品分类列表
     */
    public function adminindex()
    {
        $model = new CategoryModel;
        $list = $model->getCategorytree([],$this->getSupplierId());
        return $this->renderSuccess('', compact('list'));
    }

    /**
     * 权限状态
     */
    public function status()
    {
    	$postData = $this->request->post();
        $model = new CategoryModel();
        if ($model->setStatus($postData,$this->getSupplierId())) {
            return $this->renderSuccess('修改成功');
        }
        return $this->renderError($model->getError() ?:'修改失败');
    }

}
